﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace VTFC
{
    // ----------------------------------------------------------------------------
    /// <summary>
    /// ListViewItem for binding of <see cref="VTFC.Task"/> instance.
    /// </summary>
    // ----------------------------------------------------------------------------
    public class ListViewItemTask : ListViewItem
    {
        /// <summary><see cref="VTFC.Task"/> instance.</summary>
        private Task task = null;

        // ----------------------------------------------------------------------------
        /// <summary>
        /// <see cref="VTFC.Task"/> instance.
        /// </summary>
        // ----------------------------------------------------------------------------
        public Task Task
        {
            get
            {
                return task;
            }
            set 
            {
                task = value;
                this.SubItems.Add(GetTaskTypeText(task.TaskType));
                this.SubItems.Add(task.RelativePath);
                this.SubItems.Add(BaseLogic.GetSizeDisplay(task.MetaData.Size));
            }
        }//prop Task
               
        // ----------------------------------------------------------------------------
        /// <summary>
        /// Costructor.
        /// </summary>
        // ----------------------------------------------------------------------------
        public ListViewItemTask()
        {
        }//ctor

        private string GetTaskTypeText(TaskType type)
        {
            string text = "";
            switch (type)
            {
                case TaskType.COMFIRM_THAN_UPDATE:
                    text = Resources.TaskType_COMFIRM_THAN_UPDATE;
                    break;
                case TaskType.DOWNLOAD_AND_CREATE:
                    text = Resources.TaskType_DOWNLOAD_AND_CREATE;
                    break;
                case TaskType.DOWNLOAD_AND_UPDATE:
                    text = Resources.TaskType_DOWNLOAD_AND_UPDATE;
                    break;
            }
            return text;
        }//func GetTaskTypeText
    }//class ListViewItemTask
}//namespace VTFC
